# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=scribus
pkgver=1.6.2
pkgrel=0
pkgdesc="libre desktop publishing"
url="https://www.scribus.net/"
arch="all !s390x" # s390x doesn't have podofo package
license="GPL-2.0-or-later"
options="!check" # no test
makedepends="
	boost-dev
	cmake
	cairo-dev
	cups-dev
	harfbuzz-dev
	hunspell-dev
	lcms2-dev
	libcdr-dev
	libfreehand-dev
	libmspub-dev
	libpagemaker-dev
	libqxp-dev
	libvisio-dev
	libzmf-dev
	mesa-dev
	podofo-dev
	poppler-dev
	python3-dev
	qt5-qttools
	qt5-qttools-dev
	qt5-qtbase-dev
	samurai
	"
subpackages="$pkgname-doc $pkgname-lang"
source="
	https://downloads.sourceforge.net/scribus/scribus-$pkgver.tar.xz
	musl-types.patch
	no-execinfo.patch
	"

langdir="/usr/share/scribus/translations"
build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DWANT_DISTROBUILD=True \
		-DWANT_CPP17=True \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
2f691c1f6b7beada89be410a2936b23641913bf26bd2152974bbaa747aeafb05aa797356a85bd55c14f60f0031ce1addedc9a3ce3e92546ebbb45f96a5ff3e62  scribus-1.6.2.tar.xz
5d01d2da8ba569efa3809d8fbfe83bfb011516edd4297ad50eb1a1b560c803e4db8e7d9bf71b2520bf65e8eaa28f6d5baaa1215091d1826ed49af1c511400767  musl-types.patch
e43f7dcb7005e9d51165bc61e6c150a1e51dea6f95cc00fa0b05a11ef2820a5b23018a9aaeac5285acc7fd6b7493f4dc4332210963a288838d30313ffaf42e47  no-execinfo.patch
"
